<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<script type="text/javascript">

$(function(){
	//初始化表单验证
	$("#addForm").validate({
		rules: {
			gbprice: {isMoney: true},
		},
		messages: {
			name: {required: "请输入商品标题"},
			
		},
		submitHandler:function(form){
			$(form).ajaxSubmit({
				success:function(data){
					switch(data.flag){
					case 2:
						Kit.alert("请选择商品分类");return;
					/* case -1:
						Kit.alert("网络繁忙...，请重试");return;  */
					case  -1:
						/* dataPaginator.loadPage(1); */
						editDialog.close();
						return;
					}
				}
			});
		}
	});
}); 
/* 
 <td>
<table class="table table-bordered table-striped" width="800px">
	<thead>
		<tr>
			<td><input type="checkbox" class="icheckbox_square-blue"></td>
			<td>属性名称</td>
			<td>属性值</td>
			<td>操作</td>
		</tr>
	</thead>
</table>
	<tbody>
		<tr ng-repeat="customItem in entity.customAttributeItems">
			<td><input type="checkbox" class="icheckbox_square-blue"></td>
			<td><input class="form-control" ng-model="customItem.text" placeholder="属性名称"></td>
			<td><input class="form-control" ng-model="customItem.text" placeholder="属性值"></td>
			<td><button type="button" class="btn btn-default"
					title="删除" ng-click="deleTableRow($index)">
					<i class="fa fa-trash-o"></i> 删除
				</button></td>
		</tr>
	</tbody>

</td> */
/* 点击新增规格选项 */ 
$(document).ready(function(){
    $("#addTemplate").click(function(){
    	var tr="<tr><td><input class=\"form-control\" name=\"iname\" placeholder=\"属性名称\">"+
    		"<td><input class=\"form-control\" name=\"idetail\" placeholder=\"属性值\">"+
			"</td><td><input type=\"checkbox\" name=\"check\" checked=\"checked\" />"+
			"</td></tr>";
			$("#table").append(tr);
    });
    $("#deleteTemplate").click(function(){
        var check = document.getElementsByName("check");
        for(var i=0;i<check.length;i++){
            if(check[i].checked){
                 document.getElementById('table').deleteRow(i);
                 i--;
            }
        }
    });

    /* var content = ${GoodsTemplate.items}
    array = content.split(';');
    console.log(array); */
})

</script>
<form id="addForm" action="${BASE_PATH}/bus/goods/template/doEdit" method="post" class="form-horizontal" >
	<!-- 编辑窗口 -->	
		<div>
			<table class="table table-bordered table-striped">
				<tr>
					<td>模板名称</td>
					<td>
						<input class="form-control" placeholder="属性名称" id="name" name="name" value = "${GoodsTemplate.name}">
						<input  type="text" name="id" id="id" value="${GoodsTemplate.id}" size="12" hidden="hidden" placeholder="模板id" />
					</td>
				</tr>
				<%-- <tr>
					<td>商品分类</td>
					<td>
						<select id="categoryonid" name="categoryonid" class="selectpicker pull-left p-l-5" data-width="120px" data-url="${BASE_PATH}/api/category" data-val="${GoodsTemplate.categoryonid }" data-isfirst="true" data-next="#categorytwid" data-key="id:name" disabled="disabled"></select>
						<select id="categorytwid" name="categorytwid" class="selectpicker pull-left p-l-5" data-width="120px" data-url="${BASE_PATH}/api/categorys/{value}" data-val="${GoodsTemplate.categorytwid }" data-key="id:name" disabled="disabled"></select>
					</td>
				</tr> --%>
				<tr>
					<td>关联规格</td>
					<td>
						<input class="form-control" placeholder="属性名称" id="specids" name="specids" value = "${GoodsTemplate.spec}" disabled="disabled">
					</td>
				</tr>
			</table>
		</div>
		<div class="row">
		<div class="col-lg-6"><button class="btn btn-primary col-sm-3 pull-right" type="submit" autocomplete="off" >提交</button></div>
		<div class="col-lg-6"><button class="btn btn-default col-sm-3 pull-left"  type="button" onclick="javascript:editDialog.close();" autocomplete="off">取消</button></div>
	</div>
</form>